package controllers

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	"xiegao/models"
)

type ProductController struct {
	beego.Controller
}

// @router /product [get]
func (self *ProductController) List() {
	o := orm.NewOrm()
	var res []models.Shop
	num, error := o.QueryTable("shop").All(&res)
	if error != nil {
		fmt.Print(error)
		self.Data["json"] = map[string]interface{}{
			"code": 200,
			"msg":  "获取失败服务器繁忙",
		}
		self.ServeJSON()
		self.StopRun()
	}
	self.Data["json"] = map[string]interface{}{
		"code": 200,
		"msg":  "获取成功",
		"data": res,
		"page": num,
	}
	self.ServeJSON()
}

// @router /product [post]
func (self *ProductController) Create() {

}

// @router /product/:id [post]
func (self *ProductController) UpdateOne() {

}

// @router /product/:id [delete]
func (self *ProductController) DeleteOnt() {

}

// @router /product/:id [get]
func (self *ProductController) GetOne() {

}
